﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <el-form ref="formRefOrder_Model" :model="stateOrder_Model.vmModel" label-width="100px">
    <div>{{$t('message.autotrans.SysBatchEditConfirm')}}</div>
    <el-row>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_OrderType_FormItem" prop="LinkedVM.OrderType" :label="$t('message.autotrans._Model_Order_Model_orderType')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.OrderType" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_OrderCode_FormItem" prop="LinkedVM.OrderCode" :label="$t('message.autotrans._Model_Order_Model_orderCode')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Order_Model_orderCode')}), trigger: 'blur' }]" >
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.OrderCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_OrderQty_FormItem" prop="LinkedVM.OrderQty" :label="$t('message.autotrans._Model_Order_Model_orderQty')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Order_Model_orderQty')}), trigger: 'blur' }]" >
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.OrderQty" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_Order_Status_FormItem" prop="LinkedVM.Order_Status" :label="$t('message.autotrans._Model_Order_Model_order_Status')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Order_Model_order_Status')}), trigger: 'blur' }]" >
          <el-select v-model="stateOrder_Model.vmModel.LinkedVM.Order_Status" clearable>
             <el-option key="CREATE" value="CREATE" :label="$t('message.autotrans._Enum_OrderStatus_CREATE')"></el-option>
             <el-option key="ISSUE" value="ISSUE" :label="$t('message.autotrans._Enum_OrderStatus_ISSUE')"></el-option>
             <el-option key="PRODUCE" value="PRODUCE" :label="$t('message.autotrans._Enum_OrderStatus_PRODUCE')"></el-option>
             <el-option key="STOP" value="STOP" :label="$t('message.autotrans._Enum_OrderStatus_STOP')"></el-option>
             <el-option key="CANCEL" value="CANCEL" :label="$t('message.autotrans._Enum_OrderStatus_CANCEL')"></el-option>
             <el-option key="FINISH" value="FINISH" :label="$t('message.autotrans._Enum_OrderStatus_FINISH')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_MaterialCode_FormItem" prop="LinkedVM.MaterialCode" :label="$t('message.autotrans._Model_Order_Model_materialCode')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.MaterialCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_MaterialId_FormItem" prop="LinkedVM.MaterialId" :label="$t('message.autotrans._Model_Order_Model_materialId')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.MaterialId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_MaterialName_FormItem" prop="LinkedVM.MaterialName" :label="$t('message.autotrans._Model_Order_Model_materialName')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.MaterialName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_MaterialVersion_FormItem" prop="LinkedVM.MaterialVersion" :label="$t('message.autotrans._Model_Order_Model_materialVersion')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.MaterialVersion" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_ScheduleCode_FormItem" prop="LinkedVM.ScheduleCode" :label="$t('message.autotrans._Model_Order_Model_scheduleCode')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.ScheduleCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_ScheduleQty_FormItem" prop="LinkedVM.ScheduleQty" :label="$t('message.autotrans._Model_Order_Model_scheduleQty')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.ScheduleQty" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_ScheduleEditTime_FormItem" prop="LinkedVM.ScheduleEditTime" :label="$t('message.autotrans._Model_Order_Model_scheduleEditTime')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.ScheduleEditTime" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_ScheduleId_FormItem" prop="LinkedVM.ScheduleId" :label="$t('message.autotrans._Model_Order_Model_scheduleId')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.ScheduleId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_ScheduleStationId_FormItem" prop="LinkedVM.ScheduleStationId" :label="$t('message.autotrans._Model_Order_Model_scheduleStationId')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.ScheduleStationId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_MOrderStatus_FormItem" prop="LinkedVM.MOrderStatus" :label="$t('message.autotrans._Model_Order_Model_MOrderStatus')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.MOrderStatus" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_WorkshopCode_FormItem" prop="LinkedVM.WorkshopCode" :label="$t('message.autotrans._Model_Order_Model_workshopCode')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.WorkshopCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_WorkshopName_FormItem" prop="LinkedVM.WorkshopName" :label="$t('message.autotrans._Model_Order_Model_workshopName')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.WorkshopName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_LineCode_FormItem" prop="LinkedVM.LineCode" :label="$t('message.autotrans._Model_Order_Model_lineCode')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Order_Model_lineCode')}), trigger: 'blur' }]" >
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.LineCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_LineName_FormItem" prop="LinkedVM.LineName" :label="$t('message.autotrans._Model_Order_Model_lineName')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.LineName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_StationCode_FormItem" prop="LinkedVM.StationCode" :label="$t('message.autotrans._Model_Order_Model_stationCode')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Order_Model_stationCode')}), trigger: 'blur' }]" >
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.StationCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_StationName_FormItem" prop="LinkedVM.StationName" :label="$t('message.autotrans._Model_Order_Model_stationName')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.StationName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_EquipmentCode_FormItem" prop="LinkedVM.EquipmentCode" :label="$t('message.autotrans._Model_Order_Model_equipmentCode')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.EquipmentCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_StartTime_FormItem" prop="LinkedVM.StartTime" :label="$t('message.autotrans._Model_Order_Model_startTime')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.StartTime" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_EndTime_FormItem" prop="LinkedVM.EndTime" :label="$t('message.autotrans._Model_Order_Model_endTime')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.EndTime" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="6" class="mb20">
      <el-form-item ref="LinkedVM_FactoryCode_FormItem" prop="LinkedVM.FactoryCode" :label="$t('message.autotrans._Model_Order_Model_factoryCode')">
          <el-input v-model="stateOrder_Model.vmModel.LinkedVM.FactoryCode" clearable></el-input>
      </el-form-item>

      </el-col>
    </el-row>

    <div style="text-align:right;">
      <WtmButton @click="onSubmitOrder_Model"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

      <WtmButton @click="onCloseOrder_Model"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

    </div>

  </el-form>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageBaseInformationOrder_ModelBatchEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { order_modelApi } from '/@/api/baseinformation/order_model';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefOrder_Model = ref();
const stateOrder_Model = reactive({
    vmModel: {
	  LinkedVM:{
        OrderType: '',
        OrderCode: '',
        OrderQty: '',
        Order_Status: undefined,
        MaterialCode: '',
        MaterialId: '',
        MaterialName: '',
        MaterialVersion: '',
        ScheduleCode: '',
        ScheduleQty: '',
        ScheduleEditTime: '',
        ScheduleId: '',
        ScheduleStationId: '',
        MOrderStatus: '',
        WorkshopCode: '',
        WorkshopName: '',
        LineCode: '',
        LineName: '',
        StationCode: '',
        StationName: '',
        EquipmentCode: '',
        StartTime: '',
        EndTime: '',
        FactoryCode: '',
      },
      Ids:[],
      
	},
    
});

// 取消
const onCloseOrder_Model = () => {
    closeDialog();
};

// 提交
const onSubmitOrder_Model = () => {
	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});

    formRefOrder_Model.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            order_modelApi().batchedit(stateOrder_Model.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error:any) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
	})
};


// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateOrder_Model.vmModel.Ids = ci.attrs["wtmdata"];
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateOrder_Model.vmModel.Ids = useRouter().currentRoute.value.query.id as any;
	}

});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

